(function (window, $, undefined) {
  'use strict';

  main(function () {

    var $tableInfoPush = $('#table-infoPush');
    util.jqGrid($tableInfoPush, {
      url: '/json/test.json',
      datatype: 'json',
      autowidth: true,
      height: $(window).height() - 320,
      multiselect: true,
      multiboxonly: true,
      // shrinkToFit: false,
      colModel: [
        { name: '_id', key: true, hidden: true },
        { label: '用户名', name: '', width: 50 },
        { label: '用户电话', name: '', width: 150 },
        { label: '拉新数', name: '', width: 80 },
        { label: '总里程（km）', name: '', width: 100 },
        { label: '当月里程（km）', name: '', width: 100 },
        { label: '状态', name: '', width: 100 },
        { label: '注册日期', name: '', width: 150 }
      ],
      pager: '#pager-infoPush'
    });

    // panes
    $('#pane1').click(function () {
      setTab(1, 3);
    });

    $('#pane2').click(function () {
      setTab(2, 3);
    });

    $('#pane3').click(function () {
      setTab(3, 3);
    });

    function setTab(cursel, n) {
      for (var i = 1; i <= n; i++) {
        var s = "#pane" + i;
        var c = "#content" + i;
        if (i == cursel) {
          $(s).attr('class', 'tab-pane-selected');
          $(c).css("display", "block");
        }
        else {
          $(s).attr('class', 'tab-pane');
          $(c).css("display", "none");
        }
      }
    }

    // 推送
    $('#btn-push').click(function () {
      util.tip.warn('推送中...');
    });

    // 注册日期
    laydate.render({
      elem:'#registerDate'
    });

    // 注册到期日期
    laydate.render({
      elem:'#registerExpDate'
    });

  });


})(window, jQuery);
